<?php
require './include/global.php';
require './include/validate.php';
require './include/all_left.php';
require_once './include/advisory_db.php';
$status = $_SESSION['status'];
//print_r($_SESSION);
$smarty->compile_check = true;

$rs = $_POST;
$jobid = ($_GET[id])?$_GET[id]:$_POST[id];
if($jobid > 0){
	$jobInfo  = $DB->fetch_one_array("SELECT * FROM pa_job WHERE `jo_uid`=".$_SESSION[uid]." AND `jo_id` =".$jobid );
}


$rs['postDate'] = ($jobInfo['jo_regtime'] > 0 )?$jobInfo['jo_regtime']:time();
$smarty->display('header.tpl');

ob_clean();
ob_start();
//Preview

$title   = "<h2>Preview Job</h2>";
$cpforms->formheader(array('title'=>'Job Record','name'=>'article'));
$view = 1;

$cpforms->makehidden(array('name'=>'id','value'=>$jobid));
$cpforms->makehidden(array('name'=>'offset','value'=>$offset));
$cpforms->makehidden(array('name'=>'action','value'=>'upd_job'));
$cpforms->gethightext(array('text'=>"Create Date",'value'=>date("m/d/Y",$rs['postDate']),'view'=>"1"));
if($rs[jo_updtime]==0){$rs[jo_updtime] = $rs[jo_regtime];}
//$cpforms->gethightext(array('text'=>"Last Updated",'value'=>date("m/d/Y",$rs[jo_updtime]),'view'=>"1"));
//$cpforms->gethightext(array('text'=>"ER Job Req#",'value'=>$rs[jo_id],'view'=>"1"));

if(($_SESSION[usertype]=='recruiter')||($_SESSION[usertype]=='employer'&&$otherjob != 1)||$_SESSION[usertype]=='candidate'){
$cpforms->longline(array('title'=>"Post Options"));
$rs['jo_contact'] = @explode(",", $rs["jo_contact"]);
if(!$view){
$cpforms->getBoxes(array('one'=>1,'text'=>"Contact Guideline",'only'=>$only,'name'=>"jo_contact[]",'view'=>"$view",'selected'=>$rs[jo_contact],'option'=>$jobcontact));
}

$cpforms->makeselect(array('one'=>1,'only'=>1,'text'=>"Job Category",'name'=>"jo_cat",'selected'=>"$rs[jo_cat]",'view'=>"$view",'option'=> $jobCatOption));

if ($_SESSION[usertype] != "candidate") {
	$cpforms->gethightext(array('text'=>"Job Split Fee ($ or %)",'name'=>"jo_bonus", 'value'=>"$rs[jo_bonus]",'view'=>"$view"));
}


if('Trial' != $status)
{
	$cpforms->longline(array('title'=>"Job Poster Information"));
	$cpforms->gethightext(array('text'=>"Name",'name'=>"jo_copname",'only'=>$only,'value'=>"$rs[jo_copname]",'view'=>"$view"));
	$cpforms->gethightext(array('text'=>"Website",'name'=>"jo_copurl",'value'=>"$rs[jo_copurl]",'view'=>"$view",'url'=>1));
	if($view != 1){
	$cpforms->gethightext(array('text'=>"Contact Name",'name'=>"jo_priname",'value'=>"$rs[jo_priname]",'view'=>"$view",'icon'=>"'This information is for record keeping and internal use only.  It is not viewable by the public or recruiters.', WIDTH, 200, SHADOW, true"));
	$cpforms->gethightext(array('text'=>"Contact Email",'name'=>"jo_priemail",'value'=>"$rs[jo_priemail]",'view'=>"$view",'icon'=>"'This information is for record keeping and internal use only.  It is not viewable by the public or recruiters.', WIDTH, 200, SHADOW, true"));
	$cpforms->gethightext(array('text'=>"Contact Phone",'name'=>"jo_priphone",'value'=>"$rs[jo_priphone]",'view'=>"$view",'icon'=>"'This information is for record keeping and internal use only.  It is not viewable by the public or recruiters.', WIDTH, 200, SHADOW, true"));
	}
	$cpforms->longline(array('title'=>"Hiring Company Information"));
	$cpforms->maketextarea(array('text'=>"About the Hiring Company",'name'=>"jo_copculture",'value'=>"$rs[jo_copculture]",'view'=>"$view",'icon'=>"'Describe in 250 characters or less.  You may edit this later.', WIDTH, 200, SHADOW, true"));
	$cpforms->maketextarea(array('text'=>"Hiring Company Manager and Benefits",'name'=>"jo_copbenefit",'value'=>"$rs[jo_copbenefit]",'view'=>"$view",'icon'=>"'Describe in 250 characters or less.  You may edit this later.', WIDTH, 200, SHADOW, true"));
	}
}

$cpforms->longline(array('title'=>"Job Information"));
if($view == 1){
	echo '<tr class="firstalt" nowrap=""><td width="40%" bgcolor="#F0F0F0">Job Title:</td>
			   <td width="60%" bgcolor="#F0F0F0" style="font-weight:bold; color:blue">'.$rs[jo_title].'</td>
	</tr>';
}else{
		$cpforms->gethightext(array('text'=>"Job Title",'name'=>"jo_title",'only'=>$only,'value'=>"$rs[jo_title]",'view'=>"$view"));
}

$cpforms->gethightext(array('text'=>"Job Valid By Date",'name'=>"jo_vdate",'only'=>$only,'value'=>"$rs[jo_vdate]",'view'=>"$view"));
$cpforms->makeselect(array('text'=>"Job Fill Status",'only'=>$only,'name'=>"jo_status",'view'=>"$view",'selected'=>"$rs[jo_status]",'option'=> $jobfillstatus));
if($otherjob!=1){
$cpforms->makeselect(array('text'=>"Job Priority",'name'=>"jo_priority",'only'=>$only,'selected'=>"$rs[jo_priority]",'view'=>"$view",'option'=> $priority));
}
$cpforms->makeselect(array('text'=>"Job Type",'only'=>$only,'name'=>"jo_type",'view'=>"$view",'selected'=>"$rs[jo_type]",'option'=>$jobtype));

$cpforms->makeselect(array('text'=>"Job Industry",'name'=>"jo_category",'only'=>$only,'selected'=>"$rs[jo_category]",'view'=>"$view",'option'=> $jobcategory));
$cpforms->makeselect(array('text'=>"Job Function",'name'=>"jo_function",'only'=>$only,'selected'=>"$rs[jo_function]",'view'=>"$view",'option'=> $jobfunction));

if($otherjob!=1){
//$cpforms->gethightext(array('text'=>"Company Internal Req#",'name'=>"jo_copreq",'value'=>"$rs[jo_copreq]",'view'=>"$view",'icon'=>"'Enter an internal job code if available.', WIDTH, 200, SHADOW, true"));
}
$cpforms->gethightext(array('text'=>"No. of Open Positions",'name'=>"jo_positions",'only'=>$only,'value'=>"$rs[jo_positions]",'view'=>"$view"));
			$cpforms->gethightext(array('text'=>"Compensation(USD)",'name'=>"jo_salrange",'only'=>$only,'value'=>"$rs[jo_salrange]",'view'=>"$view"));

if($_SESSION[usertype]=='recruiter'||$_SESSION[usertype]=='employer'){
if($otherjob!=1){
$cpforms->gethightext(array('text'=>"Work Address",'only'=>$only,'name'=>"jo_address",'value'=>"$rs[jo_address]",'view'=>"$view"));
}
}
$cpforms->gethightext(array('text'=>"Location - City",'name'=>"jo_city",'only'=>$only,'value'=>"$rs[jo_city]",'view'=>"$view"));
$cpforms->makeselect(array('text'=>"Location - State/Region",'name'=>"jo_state",'only'=>$only,'selected'=>"$rs[jo_state]",'view'=>"$view",'option'=> $state));
$cpforms->makeselect(array('text'=>"Location - Country",'name'=>"jo_country",'only'=>$only,'selected'=>"$rs[jo_country]",'view'=>"$view",'option'=> $country));
$cpforms->gethightext(array('text'=>"Location - Zip Code",'name'=>"jo_zip",'only'=>$only,'value'=>"$rs[jo_zip]",'view'=>"$view"));
$cpforms->makeselect(array('text'=>"Will consider candidates how far from company location?",'name'=>"jo_howfar",'only'=>$only,'selected'=>"$rs[jo_howfar]",'view'=>"$view",'option'=> $location));
$cpforms->makeselect(array('text'=>"Job Travel Requirement(%)",'only'=>$only,'name'=>"jo_jobtravel",'selected'=>"$rs[jo_jobtravel]",'view'=>"$view",'option'=> $travel));
//$cpforms->maketextarea(array('text'=>"About the Hiring Manager",'name'=>"jo_hiringmanager",'value'=>"$rs[jo_hiringmanager]",'view'=>"$view",'icon'=>"'Please describe the hiring manager for this position in 250 characters or less.  You may edit this later.', WIDTH, 200, SHADOW, true"));
$cpforms->longline(array('title'=>"Job Qualifications"));

$cpforms->gethightext(array('text'=>"Minimum Education Requirement",'name'=>"jo_mer",'only'=>$only,'value'=>"$rs[jo_mer]",'view'=>"$view"));
$cpforms->makeselect(array('text'=>"Minimum Years of Relevant Work Experience",'name'=>"jo_myrwe",'only'=>$only,'selected'=>"$rs[jo_myrwe]",'view'=>"$view",'option'=> $yearexp2));
$cpforms->makeselect(array('text'=>"Years of People Management Experience",'name'=>"jo_ypme",'only'=>$only,'selected'=>"$rs[jo_ypme]",'view'=>"$view",'option'=> $yearexp2));
$cpforms->makeselect(array('text'=>"Years of Profit & Loss Responsibility",'name'=>"jo_yplr",'only'=>$only,'selected'=>"$rs[jo_yplr]",'view'=>"$view",'option'=> $yearexp2));
$cpforms->gethightext(array('text'=>"Industry License Requirement",'name'=>"jo_license",'value'=>"$rs[jo_license]",'view'=>"$view"));

$cpforms->gethightext(array('text'=>"Required Language Skills",'name'=>"jo_language",'value'=>"$rs[jo_language]",'view'=>"$view"));
$cpforms->gethightext(array('text'=>"Authorized to Work in Location",'name'=>"jo_authorized",'only'=>$only,'value'=>"$rs[jo_authorized]",'view'=>"$view",'icon'=>"'Please indicate the Country or Region where job candidates must have the authorization or permit to work.', WIDTH, 200, SHADOW, true"));
$cpforms->gethighradio(array('text'=>"U.S. Government Security Clearance",'name'=>"jo_usgsc",'selected'=>"$rs[jo_usgsc]",'view'=>"$view",'icon'=>"'Indicate whether or not this job requires U.S. government clearance.', WIDTH, 200, SHADOW, true"));
if('Trial' != $status)
{
	$cpforms->maketextarea2(array('text'=>"Job Description ",'name'=>"jo_description","only"=>$only,'value'=>"$rs[jo_description]",'view'=>"$view",'icon'=>"'Please include all job details here in 3,000 characters or less.  You may edit this later.', WIDTH, 200, SHADOW, true"));
}


if($_SESSION[usertype]=='recruiter'||$_SESSION[usertype]=='employer'){
$cpforms->maketextarea(array('text'=>"Public Note",'name'=>"jo_public",'value'=>"$rs[jo_public]",'view'=>"$view",'icon'=>"'Post a note about this job to Recruiters.', WIDTH, 200, SHADOW, true"));
if($otherjob!=1){
//$cpforms->maketextarea(array('text'=>"Private Note",'name'=>"jo_private",'value'=>"$rs[jo_private]",'view'=>"$view",'icon'=>"'Post a note about this job to yourself.', WIDTH, 200, SHADOW, true"));
}
}

echo "<tr class=\"tbhead\"><td colspan=\"2\" align=\"center\" bgcolor=\"#F0F0F0\"><input class=\"bginput button-secondary\" type=\"button\" value=\"Cancel\" onclick=\"history.go(-1)\">&nbsp;&nbsp;&nbsp;";
echo "</td></tr></table></td></tr></table>\n";

$reg_data = ob_get_contents();
ob_end_clean();

$smarty->assign('title',$title);

if($err!=''){
$smarty->assign("err",$err);
}

if ($_SESSION[usertype] != "candidate" && $rs[jo_cat] == '2' && $rs[jo_bonus]!='') {
	$smarty->assign("show_jobsplitfee",1);
}

$rs['jo_jobtravel'] = ($rs['jo_jobtravel']>0)?$travel[$rs['jo_jobtravel']]:'';
$rs['jo_howfar'] = ($rs['jo_howfar']>0)?$location[$rs['jo_howfar']]:'';
$rs['jo_yplr'] = ($rs['jo_yplr']>0)?$yearexp2[$rs['jo_yplr']]." yrs":'';
$rs['jo_ypme'] = ($rs['jo_ypme']>0)?$yearexp2[$rs['jo_ypme']]." yrs":'';
$rs['jo_myrwe']	 = ($rs['jo_myrwe']>0)?$yearexp2[$rs['jo_myrwe']]." yrs":'';
$rs['jo_function'] = $jobfunction[$rs['jo_function']];
$rs['jo_status'] = $jobfillstatus[$rs['jo_status']];
$rs['jo_type'] = $jobtype[$rs['jo_type']];
$rs['jo_regtime'] = date("m/d/Y",$rs['jo_regtime']);
$rs['jo_cat'] = $jobCatOption[$rs['jo_cat']];
$rs['jo_state'] = $state[$rs['jo_state']];
$rs['jo_country'] = $country[$rs['jo_country']];

print_r($rs);

$smarty->assign("rs",$rs);

$smarty->display('allleft.tpl');
$smarty->display('previewjob.tpl');
$smarty->display('allright.tpl');
$smarty->display('footer.tpl');
?>
